package jude.java.framework.definition;

/**
 * 三态
 * true, false无法描述某些状态, 用整数
 * */
public enum Tristate {
	True, False, Other;
	
	public boolean isTrue() {
		return this == True;
	}
	
	public boolean isNotTrue(){
		return this != True;
	}
	
	public boolean isFalse() {
		return this == False;
	}
	
	public boolean isNotFalse() {
		return this != False;
	}
	
	public static Tristate fromName(String v){
		try{
			Tristate t = Tristate.valueOf(v);
			return t;
		}catch (Exception e) {
		}
		return Other;
	}
	
	public static Tristate fromOri(int ori) {
		Tristate[] ts = Tristate.values();
		for (int i = 0; i < ts.length; i++) {
			if (ts[i].ordinal() == ori)
				return ts[i];
		}
		return Other;
	}
}
